import { Application } from 'egg';
import {
  loginRule
} from '../validate/passport';

/**
 * 用户相关的路由
 */
export default (app: Application) => {
  // passport.authenticate()
  return {
    'passport.login': {
      method: 'POST',
      path: '/api/passport/login',
      options: {
        tags: ['passport'],
        description: '登录',
        handler: app.controller.passport.login,
        validate: loginRule,
      },
    },
    'passport.logout': {
      method: 'GET',
      path: '/api/passport/logout',
      options: {
        tags: ['passport'],
        description: '退出登录',
        handler: app.controller.passport.logout,
      },
    },
  };
};
